﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "widgettcpcfg.h"
#include "formresponder.h"
#include "tcpresponder.h"
#include "zmqresponder.h"

#include "logger.h"
#include "formlog.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qInstallMessageHandler(Logger::CustomMessageHandler);

    TcpResponder *rep=new TcpResponder(this);
    FormResponder *w=new FormResponder(this);
    w->setComm(rep);
    ui->tabWidget->addTab(w,"tcp_responder");

    initZmq();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_actionLog_triggered()
{
    static FormLog frm;
    frm.show();
}

void MainWindow::initZmq()
{
    ZmqResponder *req=new ZmqResponder(this);
    req->setName("zmq_responder");
    FormResponder *w=new FormResponder(this);
    w->setComm(req);
    ui->tabWidget->addTab(w,"zmq_responder");
}
